'''
没有offer的解法
'''
# -*- coding:utf-8 -*-
class Solution:
    def minNumberInRotateArray(self, rotateArray):
        # write code here
        if not rotateArray:
            return 0
        return min(rotateArray)


# -*- coding:utf-8 -*-
class Solution:
    def minNumberInRotateArray(self, rotateArray):
        # write code here
        if not rotateArray:
            return 0
        rotateArray.sort()
        return rotateArray[0]
'''
有offer的解法：
二分查找，
1. 如果中间的值比左边的值大根据单调递增可知最小值一定在右边[mid+1:]，left=mid+1
2. 如果中间值比左边值小，说明数组最小值在左边以及中间[:mid+1]，right=mid
因为单调递增所以
1. 如果相邻的两个数left>right则right就是寻找的值
'''
# -*- coding:utf-8 -*-
class Solution:
    def minNumberInRotateArray(self, rotateArray):
        # write code here
        if len(rotateArray) == 0:
            return 0
        n = len(rotateArray)
        if n == 1:
            return rotateArray[0]
        left = 0
        right = n - 1
        while left < right:
            mid = (left + right) // 2
            # 顺序数组
            if rotateArray[left]<rotateArray[right]:
                return rotateArray[left]
            # 最小值在right
            if rotateArray[mid] > rotateArray[left]:
                left = mid + 1
            # 最小值在left
            elif rotateArray[mid] < rotateArray[right] :
                right = mid
            else:
                left += 1
        return rotateArray[right]
while True:
    try:
        a = list(eval(input()))
        f = Solution()
        print(f.minNumberInRotateArray(a))
    except:
        break
'''
二分查找
'''

def binary_chop(alist, data):
    """
    非递归解决二分查找
    :param alist:
    :return:
    """
    n = len(alist)
    first = 0
    last = n - 1
    while first <= last:
        mid = (last + first) // 2
        if alist[mid] > data:
            last = mid - 1
        elif alist[mid] < data:
            first = mid + 1
        else:
            return True
    return False
'''
二分查找最小值
'''

def binary_chop(alist, data):
    """
    非递归解决二分查找
    :param alist:
    :return:
    """
    n = len(alist)
    first = 0
    last = n - 1
    while first <= last:
        mid = (last + first) // 2
        if alist[mid] > data:
            last = mid - 1
        elif alist[mid] < data:
            first = mid + 1
        else:
            return True
    return False
'''
未能按时完成？应该为low+high/2
'''
# -*- coding:utf-8 -*-
class Solution:
    def minNumberInRotateArray(self, rotateArray):
        # write code here
        low = 0
        high = len(rotateArray)-1
        while low < high:
            mid = (high + low)//2
            if rotateArray[mid] > rotateArray[high]:
                low = mid + 1
            elif rotateArray[mid] < rotateArray[high]:
                high = mid
            else:
                low = low + 1
        return rotateArray[high]